<template>

    <el-container class="home-container">
        <el-header>
            <div>
                <img src="../assets/logo.png" alt class="logo_img" />
                <span>停车场管理平台</span>
            </div>
            <el-button type="info" @click="logout">安全退出</el-button>
        </el-header>
        <el-container class="menu_con">
            <el-aside >
                <el-menu background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" :router="true" :default-active="activePath">
                    <el-submenu :index="it.path"  v-for="it in menuList" :key="it.id">
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>{{it.title}}</span>
                        </template>
                        <el-menu-item-group>

                            <el-menu-item :index="item.path" v-for="item in it.slist" :key="item.id" @click="savePath">
                              <span> {{item.title}}</span>
                            </el-menu-item>

                        </el-menu-item-group>


                    </el-submenu>

                </el-menu>
            </el-aside>
        </el-container>
        <el-container class="con_plus">
            <el-main>
                <router-view></router-view>
<!--                {{menuList}}}-->
            </el-main>
        </el-container>

    </el-container>
</template>
<script>
    export default {
        data() {
            return {
                // 左侧菜单
                menuList: [],
                iconsObject: {
                    '100':'iconfont iconguanliyuan',
                    '200':'iconfont iconsport',
                    '101':'iconfont icondenglu',
                    '102':'iconfont iconmima',
                    '103':'iconfont iconsport',
                    '104':'iconfont iconshangpin',
                    '201':'iconfont iconshu',
                    '202':'iconfont iconkaluli',
                    '203':'iconfont iconshiwu',
                    '204':'iconfont icondenglu',
                },

                // 被激活的连接
                activePath:'/welcome',
            }
        },
        created(){
          this.getMenuList();
          this.activePath=window.sessionStorage.getItem('activePath');

        },
        methods: {
            logout() {
                window.sessionStorage.clear();
                this.$router.push("/login");
            },
            async getMenuList(){
               const {data:res} = await this.$http.get("menus");
                console.log(res.data);
                 if( res.status != 200) return this.$message.error("操作失败！！！");
              this.menuList = res.data;

            },
            savePath(activePath){
                window.sessionStorage.setItem('activePath',activePath);
                this.activePath=activePath;

            }
      }};
</script>
<style lang="less" scoped>
    .el-header {
        background-color: #373d41;
        display: flex;
        justify-content: space-between;// 左右贴边
        padding-left: 0%;// 左边界
        align-items: center;// 水平
        color: #fff;
        font-size: 20px;
        > div { //左侧div加布局
            display: flex;
            align-items: center;
            span {
                margin-left: 15px;
            }
        }
    }

    .logo_img{
        width: 55px;
        height: 55px;
    }
/*.con_plus{*/
/*    background-color: #E9EEF3;*/
/*    color: #333;*/
/*    !*text-align: center;*!*/
/*    !*line-height: 160px;*!*/
/*    position: fixed;*/
/*    width: 1200px;*/
/*    height: 100%;*/
/*    right: 0%;*/
/*}*/
/*.el-container{*/
/*    width: 300px;*/
/*}*/

    .menu_con{
        width: 300px;

    }
    .el-aside {
        background-color: #D3DCE6;
        color: #333;
        text-align: center;
        line-height: 50px;
        width: 300px;

    }

    .el-main {
        background-color: #E9EEF3;
        color: #333;
        text-align: center;
        line-height: 160px;
        position: absolute;
        top: 80px;
        width: 1300px;
        right: 0px;
    }




</style>
